//
// Created by 14590 on 25-9-2.
//

#include "key_driver.h"


Key_TypeDef Key[8][4];
uint8_t KeyState[8];
uint8_t KeyStateLast[8];


void KeyInit() {
    for (uint8_t i = 0; i < 8; i++) {
        for (uint8_t j = 0; j < 4; j++) {
            Key[i][j].State_Base = i;
            Key[i][j].State_Bias = j;
            Key[i][j].Allowed = 0;
        }
    }
}


uint8_t Get_KeyIsAllowed(Key_TypeDef *Key) {
    uint8_t isAllowed = Key->Allowed;
    Key->Allowed = 0;
    return isAllowed;
}

uint8_t Get_AllKeyIsAllowed() {
    uint8_t isAllowed = Key[1][0].Allowed;
    for (uint8_t i = 0; i < 8; i++) {
        for (uint8_t j = 0; j < 4; j++) {
            if (Key[i][j].Allowed == 1) isAllowed = 1;
            Key[i][j].Allowed = 0;
        }
    }
    return isAllowed;
}